#version 450 core
in vec3 dist;
out vec4 fragment_color;
layout (location = 3) uniform float line_width;
layout (location = 4) uniform vec3 color;
layout (location = 5) uniform vec3 line_color;

float edge_factor(float width) 
{
    vec3 d = fwidth(dist);
    vec3 a3 = smoothstep(vec3(0.0), d * width, dist);
    return min(min(a3.x, a3.y), a3.z);
}

void main()
{
    vec4 fill = vec4(color, 1.0);
    vec4 stroke = vec4(line_color, 0.0);
    fragment_color = mix(stroke, fill, edge_factor(line_width));
}
